home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 #2 / Ham Radio 2000 - Volume 2.iso / HAMV2 / TCP_IP / TNOS230S / CHECKCAT.C < prev    next >
Encoding:
C/C++ Source or Header  |  1996-06-22  |  951 b   |  44 lines

  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. #ifndef _lint
  5. static char rcsid[] OPTIONAL = "$Id: checkcat.c,v 1.6 1996/06/22 18:20:37 root Exp root $";
  6. #endif
  7.  
  8.  
  9. #define CATFILE        "/etc/catalog.cat"
  10.  
  11. #define NULLFILE    ((FILE *)0)
  12.  
  13. int
  14. main (void)
  15. {
  16. char buffer[256];
  17. FILE *cat;
  18. long datasize = 0;
  19. int numstrings = 0;
  20.  
  21.     /* open the input catalog file */
  22.     if ((cat = fopen (NOSDIR CATFILE, "rt")) == NULLFILE)    {
  23.         printf ("checkcat: can't open '%s'\n", CATFILE);
  24.         return (1);
  25.     }
  26.  
  27.     /* read the identification record as the first one in the cat file */
  28.     if (fread (buffer, 1, 256, cat))
  29.         printf (buffer);
  30.  
  31.     /* loop while there is data left in the data file */
  32.     while (fread (buffer, 1, 256, cat))    {
  33.         datasize += (long) strlen(buffer);
  34.         numstrings++;
  35.     }
  36.  
  37.     fclose (cat);
  38.  
  39.     /* tell the user all is well */
  40.     printf ("checkcat: %ld bytes of string data (%d lines) in catalog file!\n", datasize, numstrings);
  41.     return 0;
  42. }
  43.  
  44.